using GameLogic;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;


    [RequireComponent(typeof(SlotUI))]
    public class ShowItemTooltip : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
    {
        private SlotUI slotUI;

        private void Awake()
        {
            slotUI = GetComponent<SlotUI>();
        }


        public void OnPointerEnter(PointerEventData eventData)
        {
            if (slotUI.itemDetails != null)
            {
                UIModule.Instance.GetUIAsync<MainUI>((data) =>
                {
                    data.ItemTooltipPanel.gameObject.SetActive(true);
                    data.ItemTooltipPanel.SetupTooltip(slotUI.itemDetails, slotUI.slotType);
                    data.ItemTooltipPanel.transform.position = transform.position + Vector3.up * 0.6f;
                });
            }
            else
            {
                UIModule.Instance.GetUIAsync<MainUI>((data) =>
                {
                    data.ItemTooltipPanel.gameObject.SetActive(false);
                });
            }
        }

        public void OnPointerExit(PointerEventData eventData)
        {
            UIModule.Instance.GetUIAsync<MainUI>((data) =>
            {
                data.ItemTooltipPanel.gameObject.SetActive(false);
            });
        }

    }